/*
 * fibonacci.cpp
 *
 *  Created on: Aug 21, 2012
 *      Author: xkq
 */

#include <iostream>
using namespace std;

int fibo_recursive(int n){
	if(n==0) return 0;
	if(n==1) return 1;
	return fibo_recursive(n-1)+fibo_recursive(n-2);
}

int fibo_iterative(int n){
	int fibo1=0;
	int fibo2=1;
	int fibo3=0;
	for(int i=2;i<=n;i++){
		fibo3=fibo1+fibo2;
		fibo1=fibo2;
		fibo2=fibo3;
	}
	return fibo3;
}

//int main(){
//	cout<<fibo_iterative(6)<<endl;
//	return 0;
//}


